<?php session_start();
if (isset($_SESSION["id"]))
    header("Location: http://localhost/nhomtt-web2/index.php?uid=".$users[$index]['id']);
?>
<section id="cottrai">
                            <form method="POST">
                                <div id="noidung">
                                    <table class="table">
                                        <tr>
                                            <td>Email Address: </td>
                                            <td><input id="username" name="username" type="text" size="20"></td>
                                        </tr>
                                        <tr>
                                            <td>Password: </td>
                                            <td><input id="password" name="password" type="password" size="20"><br />
                                                    <a href="">Forgot your password?</a></td>
                                        </tr>
                                        <tr>
                                            <td></td>
                                            <td><input type="checkbox" name="checkbox" value="check ked"> 
                                                    Remember me on this computer </td>  
                                        </tr>
                                    </table>  
                                    <p align="center"><input id="submit"   name="submit"   type="submit" value="Enter"></p>

                                </div><!--the end noi dung cot trai--->
                            </form>
                            <?php
                            require_once 'Model/use.php';
                            
                            if (isset($_POST['submit'])) {
                                $username = $_POST['username'];
                                $password = $_POST['password'];
                                $Ok = FALSE;
                                $index = -1;
                               
                                for ($i = 0; $i < count($users); $i++) {
                                    if ((strcmp($users[$i]['username'], $username) == 0) &&
                                            (strcmp($users[$i]['password'], $password) == 0)) {
                                        $Ok = TRUE;
                                         if ($Ok) {
                                             $_SESSION["id"]=$users[$i]["id"];
                                             header("Location: http://localhost/nhomtt-web2/index.php");
                                         } else {
                                                echo "nhap lai";   
                                            }
                                }
                               
                                }
                            }
                           
                            ?>
                        </section>